from django import forms
from django.contrib.auth.forms import AuthenticationForm

from users.models import User
from tasks.models import Comment


class UserLoginForm(AuthenticationForm):

    class Meta:
        model = User
        fields = ['email', 'password']

    username = forms.CharField(label='email')
    password = forms.CharField(label='password', widget=forms.PasswordInput)


class ChangeProfileForm(forms.ModelForm):

    city = forms.CharField(label='Город', max_length=60, required=False)
    display_name = forms.CharField(label='Имя', max_length=50)
    send_message = forms.BooleanField(label='Получать почту', required=False)
    country = forms.CharField(label='Страна', max_length=50, required=False)
    about = forms.CharField(label='О себе', widget=forms.Textarea, max_length=250, required=False)
    avatar = forms.ImageField(required=False)
    background_image = forms.ImageField(required=False)

    class Meta:
        model = User
        fields = ['display_name', 'city', 'country', 'about', 'avatar', 'background_image', 'send_message']


class UserRegisterForm(forms.ModelForm):
    class Meta:
        model = User
        fields = ['email',]
        
        email = forms.CharField(label='email')


class PasswordChangeForm(forms.Form):
    email = forms.CharField(label='email')


class SendMessageForm(forms.ModelForm):

    author = forms.CharField(max_length=150, required=False)
    body = forms.CharField(max_length=500, required=False)
    
    class Meta:
        model = Comment
        fields = ['author', 'body']